package com.fau.fm.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * 药品类别表id
 * @author liy
 * @since 2014年7月24日,下午6:40:47
 */
@Entity
@Table(name = "medical_medicine_sort")
public class MedicalMedicineSort implements Serializable, JSONAware {

	private static final long serialVersionUID = 8841844451877475661L;

	private String id;
	
	@NotEmpty(message = "类别名称不能为空！")
	@Length(max = 16, message = "类别名称长度需要在0和16之间")
	private String name;						// 名称
	
	@NotEmpty(message = "父类别id不能为空")
	@Length(max = 32, message = "类别名称长度需要在0和32之间")
	private String pid;							// 父类别id
	
	@NotEmpty(message = "操作用户id不能为空")
	@Length(max = 32, message = "类别名称长度需要在0和32之间")
	private String userId;						// 操作用户id
	
	@NotNull(message = "创建日期不能为空")
	private Date createTime = new Date();		// 创建日期
	
	@NotNull(message = "更新日期不能为空")
	private Date updateTime = new Date();		// 更新日期
	
	@NotNull(message = "医院标识id不能为空")
	@Length(max = 32, message = "类别名称长度需要在0和32之间")
	private String hospitalId;					//医院标志ID
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@Column(name = "name", length = 50)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "pId", length = 32)
	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	
	@Column(name = "user_id", length = 32)
	public String getUserId() {
		return userId;
	}
	
	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "update_time")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "hospital_id")
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("name", name);
		obj.put("pid", pid);
		obj.put("userId", userId);
		
		return obj.toString();
	}
	
	
	
}
